﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Management;

namespace Light.Utility
{
    public class HardDisk
    {
        
        private string _model = null;
        private string _serialNo = null;
        private string _type = null;

        
        private HardDisk()
        {
        }

        internal static HardDisk[] Get()
        {
            HardDisk disk;
            List<HardDisk> list = new List<HardDisk>();
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
            foreach (ManagementObject obj2 in searcher.Get())
            {
                disk = new HardDisk
                {
                    _model = obj2["Model"].ToString(),
                    _type = obj2["InterfaceType"].ToString()
                };
                list.Add(disk);
            }
            searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
            int num = 0;
            foreach (ManagementObject obj2 in searcher.Get())
            {
                disk = list[num];
                if (obj2["SerialNumber"] == null)
                {
                    disk._serialNo = string.Empty;
                }
                else
                {
                    disk._serialNo = obj2["SerialNumber"].ToString().Trim();
                }
                num++;
            }
            return list.ToArray();
        }

        
        public string InterfaceType
        {
            get
            {
                return this._type;
            }
        }

        public string Model
        {
            get
            {
                return this._model;
            }
        }

        public string SerialNumber
        {
            get
            {
                return this._serialNo;
            }
        }
    }

}
